package com.dawan.sbjy.service.impl;

import com.dawan.sbjy.service.ifac.MailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.MailException;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;

@Service
public class MailServiceImpl implements MailService {
    @Autowired
    private JavaMailSender mailSender;
    @Value("${spring.mail.username}")
    private String from;
    @Override
    public void sendSimpleMail(String to, String subject, String content) throws MailException {
        SimpleMailMessage sendemail = new SimpleMailMessage();
        sendemail.setFrom(from); // 邮件发送者
        sendemail.setTo(to); // 邮件接受者
        sendemail.setSubject(subject); // 主题
        sendemail.setText(content); // 内容
        mailSender.send(sendemail);
    }
}
